<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="dist/css/bootstrap.min.css">
<link rel="stylesheet" href="my.css">
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
<script src="http://www.jq22.com/jquery/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="jquery.jqprint-0.3.js"></script>
<script src="dist/js/bootstrap.min.js"></script>
<script type="text/javascript">
	$(function() {
		
	$(".dropdown-list>li>button[class='btn btn-primary submit']").click(function() {
		$(this).closest("ul").hide();
		//表单提交按钮和清空按钮
		$("#submit").show();
		$("#cancle").show();
	})
		
	$(".dropdown-list>li>button[class='btn btn-default cancle']").click(function() {
		$(".dropdown-list").hide();
		//表单提交按钮和清空按钮
		$("#submit").show();
		$("#cancle").show();
		$(this).closest("ul").find("input").attr("checked",false);
	})	
		
	
	$("#muscle_div>span[class='input-group-btn']").click(function() {
		$(".dropdown-list").hide();
		//表单提交按钮和清空按钮
		$("#submit").hide();
		$("#cancle").hide();
		var local=$(this).children("button").html();
		if(local.indexOf("颈椎")>0){
			$("#muscle_c").show();
		}else if(local.indexOf("胸椎")>0){
			$("#muscle_t").show();
		}else if(local.indexOf("腰椎")>0){
			$("#muscle_l").show();
		}else{
			$("#muscle_s").show();
		}
	});
	$("#motion_div>span[class='input-group-btn']").click(function() {
		$(".dropdown-list").hide();
		//表单提交按钮和清空按钮
		$("#submit").hide();
		$("#cancle").hide();
		var local=$(this).children("button").html();
		if(local.indexOf("颈椎")>0){
			$("#motion_c").show();
		}else if(local.indexOf("胸椎")>0){
			$("#motion_t").show();
		}else if(local.indexOf("腰椎")>0){
			$("#motion_l").show();
		}else{
			$("#motion_s").show();
		}
	});
	
	
	
	getCheckDoctor();	
	function getCheckDoctor(){
		$.ajax({
			type : "post",
			async : true,//异步，如果等于false 那么就是同步
			url : "checkDoctor",
			dataType : "text",
			success : function(msg) {//ajax返回成功后做处理
				$("#checkDoctor").val(msg);
				
			},
			error : function(msg) {
				alert("连接服务器出错，请于管理员联系! ");
			}
		});
	}
		
		
		$("#cancle").click(function() {
			$("input[type='text']").val("");
			$(".dropdown-list").hide();
			$(".dropdown-list").find("input").attr("checked",false);
		});
		var reportURL;
		$("#download").click(function() {
			window.open(reportURL);
		});
		
		$("#goBack").click(function() {
		    console.debug();
			$("#report_div").hide();
			$("input[type='text']").val("");
			getCheckDoctor();
			$("#information").show();
		});
		
		
    		$("#print_report").click(function() {
                
         		 $("#report").jqprint();

                });
                

		
		function cleanForm(){
			$("input[type='text']").val("");
			$("#information").hide();
			$(".dropdown-list").find("input").attr("checked",false);
		}
		
		function reportShow(mesage,fileURL){
			$("#report_div").show();
			$("#report_div").css("width","50%");
			$("#report_div").css("margin-top","5%");
			$("#report_div").css("margin-left","20%");
			$("#report").html("");
			$("#report").html(mesage);
			reportURL=fileURL;
		}
		
		$("#submit").click(function() {
			
			var muscle="";
			var motion=""; 
			$("#muscle_ul_li").find("input[type=checkbox]:checked").each(function(index,value){
				if( muscle==""){
					 muscle=$(value).val()
				}else{
					 muscle=muscle+","+$(value).val();
					
				}
				
			})
			
			$("#motion_ul_li").find("input[type=checkbox]:checked").each(function(index,value){
				if( motion==""){
					motion=$(value).val()
				}else{
					motion=motion+","+$(value).val();
					
				}
			})
			console.log(motion);
			
			if($("#checkNumber").val()==""||
			$("#customer").val()==""||
			$("#checkDoctor").val()==""||
			muscle==""||
			motion==""){
				alert("每一项都不能为空!");
				return;
			}
			
			$.ajax({
				type : "post",
				async : true,//异步，如果等于false 那么就是同步
				url : "report?",
				dataType:'text',
				data: {
					"checkNumber":$("#checkNumber").val(),
					"customer":$("#customer").val(),
					"customerSex":$("input[type='radio']:checked").val(),
					"checkDoctor":$("#checkDoctor").val(),
					"muscleTone":muscle,
					"joinMotion":motion,
				},
				dataType : "json",
				success : function(msg) {//ajax返回成功后做处理
					cleanForm();
					reportShow(msg.reprotFile,msg.reprotURL);
				},
				error : function(msg) {
					alert("连接服务器出错，请于管理员联系!");
				}
			});

		})

	});
</script>

</head>
<body>
	<div id="information" style="width: 30%; margin-top: 10%; margin-left: 30%">
			<div class="input-group">
				<span class="input-group-addon">体检编号&nbsp;&nbsp;</span> <input name="checkNumber" id="checkNumber"
					type="text" class="form-control" placeholder="体检单编号">
			</div>
			<br />
			<div class="input-group">
				<span class="input-group-addon">姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名&nbsp;&nbsp;</span>
				<input id="customer" name="customer" type="text" class="form-control" placeholder="被检测人姓名">
			</div>
			<br />
			<div class="input-group">
				<span class="input-group-addon">性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别&nbsp;&nbsp;
				</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label
					class="checkbox-inline"><input type="radio"
					name="customerSex"  value="男"
					checked>男 </label> <label class="checkbox-inline"> <input
					type="radio" name="customerSex" id="optionsRadios4"
					value="女">女
				</label>
			</div>
			<br />
			<div class="input-group">
				<span class="input-group-addon">检测医师&nbsp;&nbsp;</span> <input
					id="checkDoctor" name="checkDoctor" type="text" class="form-control" placeholder="医师姓名">
			</div>
			<br />
			<div class="input-group" id="muscle_div">
				<span class="input-group-addon">肌肉张力&nbsp;&nbsp;</span>
				<span class="input-group-btn">
					<button type="button" class="btn btn-default dropdown-toggle"
						data-toggle="dropdown">
						颈椎
						<span class="caret"></span>
					</button>
				</span>
				<span class="input-group-btn">
					<button type="button" class="btn btn-default dropdown-toggle"
						data-toggle="dropdown">
						胸椎
						<span class="caret"></span>
					</button>
				</span>
				<span class="input-group-btn">
					<button type="button" class="btn btn-default dropdown-toggle"
						data-toggle="dropdown">
						腰椎
						<span class="caret"></span>
					</button>
				</span>
				<span class="input-group-btn">
					<button type="button" class="btn btn-default dropdown-toggle"
						data-toggle="dropdown">
						骶椎
						<span class="caret"></span>
					</button>
				</span>
			</div>
			<div  id="muscle_ul_li">
				<ul class="dropdown-list" id="muscle_c">
						<li>
							<label><input type="checkbox" value="OCC">OCC</label><label><input type="checkbox" value="C4">C4</label>
						</li>
						<li>
							<label><input type="checkbox" value="C1">C1&nbsp;</label> <label><input type="checkbox" value="C5">C5</label>
						</li>
						<li>
							<label><input type="checkbox" value="C2">C2&nbsp;</label> <label><input type="checkbox" value="C6">C6</label>
						</li>
						<li>
							<label><input type="checkbox" value="C3">C3&nbsp;</label> <label><input type="checkbox" value="C7">C7</label>
						</li>
						<li>
						<button type="button" class="btn btn-default cancle" style=" margin-left: 20%">取消</button>
						<button type="button" class="btn btn-primary submit" style=" margin-left: 20%">确定</button>
					   </li>
				 </ul>
				
				<ul class="dropdown-list" id="muscle_t">
						<li>
							<label><input type="checkbox" value="T1">T1</label><label><input type="checkbox" value="T5">T5</label><label><input type="checkbox" value="T9">T9</label>
						</li>
						<li>
							<label><input type="checkbox" value="T2">T2</label><label><input type="checkbox" value="T6">T6</label><label><input type="checkbox" value="T10">T10</label>
						</li>
						<li>
							<label><input type="checkbox" value="T3">T3</label><label><input type="checkbox" value="T7">T7</label><label><input type="checkbox" value="T11">T11</label>
						</li>
						<li>
							<label><input type="checkbox" value="T4">T4</label><label><input type="checkbox" value="T8">T8</label><label><input type="checkbox" value="T12">T12</label>
						</li>
						<li>
						<button type="button" class="btn btn-default cancle" style=" margin-left: 20%">取消</button>
						<button type="button" class="btn btn-primary submit" style=" margin-left: 20%">确定</button>
					   </li>
				 </ul>
				 
				 <ul class="dropdown-list" id="muscle_l">
						<li>
							<label><input type="checkbox" value="L1">L1</label><label><input type="checkbox" value="L4">L4</label>
						</li>
						<li>
							<label><input type="checkbox" value="L2">L2</label><label><input type="checkbox" value="L5">L5</label>
						</li>
						<li>
							<label><input type="checkbox" value="L3">L3</label>
						</li>
						<li>
						<button type="button" class="btn btn-default cancle" style=" margin-left: 20%">取消</button>
						<button type="button" class="btn btn-primary submit" style=" margin-left: 20%">确定</button>
					   </li>
				 </ul>
				 
				 <ul class="dropdown-list" id="muscle_s">
						<li>
							<label><input type="checkbox" value="S1">S1</label>
						</li>
						<li>
						<button type="button" class="btn btn-default cancle" style=" margin-left: 20%">取消</button>
						<button type="button" class="btn btn-primary submit" style=" margin-left: 20%">确定</button>
					   </li>
				 </ul>
			</div>
			<br />
			<div class="input-group" id="motion_div">
				<span class="input-group-addon">关节活动度</span> 
				<span class="input-group-btn">
					<button type="button" class="btn btn-default dropdown-toggle"
						data-toggle="dropdown">
						颈椎
						<span class="caret"></span>
					</button>
				</span>
				<span class="input-group-btn">
					<button type="button" class="btn btn-default dropdown-toggle"
						data-toggle="dropdown">
						胸椎
						<span class="caret"></span>
					</button>
				</span>
				<span class="input-group-btn">
					<button type="button" class="btn btn-default dropdown-toggle"
						data-toggle="dropdown">
						腰椎
						<span class="caret"></span>
					</button>
				</span>
				<span class="input-group-btn">
					<button type="button" class="btn btn-default dropdown-toggle"
						data-toggle="dropdown">
						骶椎
						<span class="caret"></span>
					</button>
				</span>
			</div>
			<div id="motion_ul_li">
				<ul class="dropdown-list" id="motion_c">
						<li>
							<label><input type="checkbox" value="OCC">OCC</label><label><input type="checkbox" value="C4">C4</label>
						</li>
						<li>
							<label><input type="checkbox" value="C1">C1&nbsp;</label> <label><input type="checkbox" value="C5">C5</label>
						</li>
						<li>
							<label><input type="checkbox" value="C2">C2&nbsp;</label> <label><input type="checkbox" value="C6">C6</label>
						</li>
						<li>
							<label><input type="checkbox" value="C3">C3&nbsp;</label> <label><input type="checkbox" value="C7">C7</label>
						</li>
						<li>
						<button type="button" class="btn btn-default cancle" style=" margin-left: 20%">取消</button>
						<button type="button" class="btn btn-primary submit" style=" margin-left: 20%">确定</button>
					   </li>
				 </ul>
				
				<ul class="dropdown-list" id="motion_t">
						<li>
							<label><input type="checkbox" value="T1">T1</label><label><input type="checkbox" value="T5">T5</label><label><input type="checkbox" value="T9">T9</label>
						</li>
						<li>
							<label><input type="checkbox" value="T2">T2</label><label><input type="checkbox" value="T6">T6</label><label><input type="checkbox" value="T10">T10</label>
						</li>
						<li>
							<label><input type="checkbox" value="T3">T3</label><label><input type="checkbox" value="T7">T7</label><label><input type="checkbox" value="T11">T11</label>
						</li>
						<li>
							<label><input type="checkbox" value="T4">T4</label><label><input type="checkbox" value="T8">T8</label><label><input type="checkbox" value="T12">T12</label>
						</li>
						<li>
						<button type="button" class="btn btn-default cancle" style=" margin-left: 20%">取消</button>
						<button type="button" class="btn btn-primary submit" style=" margin-left: 20%">确定</button>
					   </li>
				 </ul>
				 
				 <ul class="dropdown-list" id="motion_l">
						<li>
							<label><input type="checkbox" value="L1">L1</label><label><input type="checkbox" value="L4">L4</label>
						</li>
						<li>
							<label><input type="checkbox" value="L2">L2</label><label><input type="checkbox" value="L5">L5</label>
						</li>
						<li>
							<label><input type="checkbox" value="L3">L3</label>
						</li>
						<li>
						<button type="button" class="btn btn-default cancle" style=" margin-left: 20%">取消</button>
						<button type="button" class="btn btn-primary submit" style=" margin-left: 20%">确定</button>
					   </li>
				 </ul>
				 
				 <ul class="dropdown-list" id="motion_s">
						<li>
							<label><input type="checkbox" value="S1">S1</label>
						</li>
						<li>
						<button type="button" class="btn btn-default cancle" style=" margin-left: 20%">取消</button>
						<button type="button" class="btn btn-primary submit" style=" margin-left: 20%">确定</button>
					   </li>
				 </ul>
			</div>
			<br />
			<div style="margin-left: 20%">
			<button type="button" class="btn btn-default" id="cancle">清空</button>
			<button type="button" class="btn btn-primary" id="submit" style="margin-left: 20%">提交</button>
			</div>
	</div>

	<div id="report_div" style="display: none">
		<div id="report"></div>
		<br/>
		<button type="button" class="btn btn-primary" id="goBack">返回</button>
		<button type="button" class="btn btn-default" id="print_report"  style="margin-left: 20%">打印报告</button>
		<button type="button" class="btn btn-default" id="download"  style="margin-left: 20%">下载报告</button>
	</div>

</body>
</html>
